﻿namespace Sustainalytics.ClientDW.Synchronization.Tests.IntegrationTests
{
    using System.Threading.Tasks;

    using Amazon;

    using Sustainalytics.Utils.Configuration;

    using Xunit;

    public class MachineManagerTests
    {
        private readonly IPDFMachineManagement _sut;

        public MachineManagerTests()
        {
            var accesKeyId = SettingsHelper.Read<string>("accesKeyId", "AKIAJKGZZMOFAVOVLHJA");
            var secretKey = SettingsHelper.Read<string>("awsSecretKey", "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");
            var regionName = SettingsHelper.Read<string>("AWSRegion", RegionEndpoint.EUWest1.SystemName);
            var region = RegionEndpoint.GetBySystemName(regionName);

            this._sut = new PDFMachineManagement("i-005bb5058f07df3ac", accesKeyId, secretKey, region);
        }

        [Fact]
        public async Task StartMachineTest()
        {
            var result = await this._sut.StartAWSInstanceAsync().ConfigureAwait(false);

            Assert.True(result);
        }

        [Fact]
        public async Task GetMachineStateTest()
        {
            var result = await this._sut.GetAWSInstanceStateAsync().ConfigureAwait(false);

            Assert.True(result != MachineState.Terminated);
        }

        [Fact]
        public async Task StopMachineTest()
        {
            var result = await this._sut.StopAWSIntanceAsync().ConfigureAwait(false);

            Assert.True(result);
        }
    }
}